<template>
  <view>
    <uni-nav-bar left-icon="back" title="发布作品" backgroundColor="rgba(0, 0, 0, 0)" color="#fff" class="fw-b" :border="false" :right-width="150" :left-width="120" @clickLeft="$tools.goBack()">
      <view class="w-150 h-58 br-6 rowsc rowsm colfff fs-30 fw-b" style="background: linear-gradient(to bottom,#4897FF,#4878FF);" slot="right" @click="publish()">发布</view>
    </uni-nav-bar>
    
    <view class="w100 pl-24 pr-24 mt-20">
      <view class="w100 h-270 br-20 p-all-30 mb-20" style="background-color: #404040;">
        <textarea value="" placeholder="请输入作品简介" v-model="content" class="w100 h100" placeholder-class="fs-18" />
      </view>
      
      <view class="w100 h-100 br-20 p-all-30 mb-20" style="background-color: #404040;">
        <input type="text" placeholder="请输入发布地点" v-model="address" class="w100 h100" placeholder-class="fs-18">
      </view>
      
      <view class="w100 rowsb rowsm">
        <video :src="url" class="w-340 h-510 br-20"></video>
        <image :src="img ? img : '/static/icon_oh.png'" class="w-340 h-510 br-20" mode="" @click="uploadImg()"></image>
      </view>
      
      <!-- <view class="w100 rowsa rowsm fs-24 colfff mt-20">
        <view class="">00:00</view>
        <view class="">上传封面</view>
      </view> -->
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        url:'',
        img:'',
        content:'',
        address:''
      };
    },
    onLoad(e) {
      this.url = e.url
    },
    methods:{
      uploadImg(){
        uni.chooseImage({
          count:1,
          success:(res) => {
            uni.uploadFile({
              url:this.$tools.httpOne + 'utils/ossUpload',
              filePath:res.tempFilePaths[0],
              name:'file',
              success:(res1) => {
                console.log(JSON.parse(res1.data))
                this.img = JSON.parse(res1.data).url
              }
            })
          }
        })
      },
      publish(){
        if(!this.content) return this.$tools.showtt('请输入简介')
        if(!this.address) return this.$tools.showtt('请输入地点')
        if(!this.img) return this.$tools.showtt('请上传封面')
        let data = {
          position:this.address,
          content:this.content,
          video:this.url,
          image:this.img
        }
        this.$tools.axiosFromToken('POST','prosp/add',{...data},'加载中').then(res => {
          this.$tools.showtt(res.msg)
          if(res.code != 200) return
          setTimeout(() => {
            this.$tools.goBack(1)
          },1000)
        })
      }
    }
  }
</script>

<style lang="scss">
page {
  background-color: #333;
}
</style>
